package com.shaco.heroproject.fragment;

import com.shaco.heroproject.R;
import com.shaco.heroproject.activity.WebWindowActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;

public class FightFragment extends Fragment implements View.OnClickListener {
    private EditText fight_edTv;
    private Spinner fightSp;
    private Button fight_findBtn;


    @Override
    @Nullable
    public View onCreateView(LayoutInflater inflater,
                             @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        return inflater.inflate(R.layout.fragment_fight, null);
//        return inflater.inflate(R.layout.fragment_fight, null);
    }

    @Override
    public void onAttach(Activity activity) {
        // TODO Auto-generated method stub
        super.onAttach(activity);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onActivityCreated(savedInstanceState);
        fight_edTv= (EditText) getActivity().findViewById(R.id.fight_edTv);
        fightSp= (Spinner) getActivity().findViewById(R.id.fightSp);
        fight_findBtn= (Button) getActivity().findViewById(R.id.fight_findBtn);
        fight_findBtn.setOnClickListener(this);
    }

    public void initView() {
        // TODO Auto-generated method stub
//        fight_edTv= (EditText) getActivity().findViewById(R.id.fight_edTv);
//        fightSp= (Spinner) getActivity().findViewById(R.id.fightSp);
//        fight_findBtn= (Button) getActivity().findViewById(R.id.fight_findBtn);
//        fight_findBtn.setOnClickListener(this);


    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.fight_findBtn:
                initData();



                break;
        }
    }
    public void initData() {
        // TODO Auto-generated method stub
        String name=fight_edTv.getText().toString();
//        String server=fightSp.getSelectedItem().toString();
        //拆分游戏区,获得数组第二个
        String[] server=fightSp.getSelectedItem().toString().split(" ");
        String url="http://zdl.mbox.duowan.com/phone/playerDetailNew.php?sn="+server[1]+"&target="+name+"&v=85&versionName=2.2.0";
        Log.i("shaco","---------"+url+"------------");

        Intent intent=new Intent();
        intent.setClass(getActivity(),WebWindowActivity.class);
        intent.putExtra("title","战绩");
        intent.putExtra("url",url);
        intent.putExtra("webKey","3");
        startActivityForResult(intent, 100);

    }
}
